package outer;

import java.util.Arrays;

public class text19 {
    /*public void moveZeroes(int[] nums) {
        int i=0;
        for(i=0;i<nums.length;i++)
        {
            if(nums[i]==0)
            {
                break;
            }

        }
        if(i==nums.length)
        {
            return;
        }
        int slow=0;
        int fast=1;
        while(fast<nums.length&&slow<nums.length&&slow<=fast)
        {
            while(slow<nums.length&&nums[slow]!=0&&slow<=fast)
            {
                slow++;

            }
            while(fast<nums.length&&nums[fast]==0&&slow<=fast)
            {
                fast++;
            }
            if(fast<=nums.length-1)
            {
                int tmp=nums[slow];
                nums[slow]=nums[fast];
                nums[fast]=tmp;
            }
            slow++;
            fast++;
        }




    }
}

    public static void moveZeroes(int[] nums) {
        int i=0;
        for(i=0;i<nums.length;i++)
        {
            if(nums[i]==0)
            {
                break;
            }
            else
            {
                return;
            }
        }
        int slow = 0;
        int fast = 1;
        while (fast < nums.length && slow < nums.length && slow <= fast) {
            while (slow < nums.length && nums[slow] != 0 && slow <= fast) {
                slow++;

            }
            while (fast < nums.length && nums[fast] == 0 && slow <= fast) {
                fast++;
            }
            if (fast <= nums.length - 1) {
                int tmp = nums[slow];
                nums[slow] = nums[fast];
                nums[fast] = tmp;
            }
            slow++;
            fast++;
        }


    }

    public static void main(String[] args) {
        int[]arr={1,2,3,1};
        moveZeroes(arr);
        System.out.println(Arrays.toString(arr));

    }

     */
    /*public static int[]addToArrayForm(int[] num, int k) {
        int i=0;
        int add=0;
        int a=0;
        for(i=num.length-1;i>=0;i--)
        {
            a=num[i]+add+k%10;

            num[i]=(num[i]+add+k%10)%10;


            add=a/10;
            k/=10;
        }
        if(add>=1)
        {
            int[]arr=new int[num.length+1];
            arr[0]=add;
            for(int j=0;j<num.length;j++)
            {
                arr[j+1]=num[j];
            }
            return arr;


        }
        else
        {
            return num;
        }






    }

    public static void main(String[] args) {
        int[]nums={2,1,5};
        int k=34;
       int[] a=addToArrayForm(nums,806);
        System.out.println(Arrays.toString(a));

    }

     */
    /*public static int findMaxConsecutiveOnes(int[] nums) {
        int start=0;
        int end=0;
        int max=0;
        int i=0;
        while(i<nums.length)
        {
            while(nums[i]!=1&&i<nums.length)
            {
                i++;
            }

            while(i<nums.length&&nums[i]==1)
            {
                start=i;
                i++;
            }
            end=i-1;
            if(end-start+1>max)
            {
                max=end-start+1;
            }


        }
        return max;



    }

    public static void main(String[] args) {
        int[]arr={1,1,0,1,1,1};
        int b=findMaxConsecutiveOnes(arr);
        System.out.println(b);
    }

     */
    public static int[] numberOfLines(int[] widths, String s) {
        int width=0;
        int i=0;
        int line=0;
        int[]arr=new int[2];
        for(i=0;i<s.length();i++)
        {

            if(width<=100)
            {

                width=width+widths[s.charAt(i)-97];
            }
            else if(width>100)
            {
                line++;
                width=widths[s.charAt(i)-97];
            }
        }
        arr[0]=line;
        arr[1]=width;
        return arr;
    }

    public static void main(String[] args) {
        int[]widths={20,30,40,50};
        String s="abcd";
        int[]arr=numberOfLines(widths,s);
        System.out.println(Arrays.toString(arr));

    }




}
